<!DOCTYPE HTML>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>所有试用</title>
    <link rel="stylesheet" type="text/css" href="../css/aui.css" />


</head>

<body>
    <header class="aui-bar aui-bar-nav aui-bar-light" id="header">
        <a class="aui-pull-left aui-btn" tapmode onclick="api.closeWin();">
            <span class="aui-iconfont aui-icon-left"></span>
        </a>
        <div class="aui-title">所有试用</div>
    </header>
    <footer class="aui-bar aui-bar-tab" id="footer" style="background:#03a9f4;color:#fff;line-height:55px;" onclick="fnTryGoods()">
        <div>免费试用</div>
    </footer>
</body>
<script type="text/javascript" src="../script/api.js"></script>
<script type="text/javascript" src="./conf/config.js"></script>
<script type="text/javascript" src="./js/common.js"></script>
<script type="text/javascript" src="../script/jquery-1.8.2.min.js"></script>
<script type="text/javascript">
    apiready = function() {
        initEventListenner(); //退出键添加提示框
        var header = $api.byId('header');
        $api.fixStatusBar($api.dom('header'));
        api.setStatusBarStyle({
            style: 'dark',
           color:'transparent'
        });
        var headerH = $api.offset(header).h;
        var footer = $api.byId('footer');
        var footerH = $api.offset(footer).h;
        // api.openFrame({
        //     name: 'ware_frame',
        //     url: './ware_frame.html',
        //     rect: {
        //         x: 0,
        //         y: headerH,
        //         w: 'auto',
        //         h: api.winHeight - footerH - headerH,
        //     },
        //     pageParam: {
        //         wareId: api.pageParam.wareId
        //     },
        //     bounces: true
        // });
    };

    function fnTryGoods() {
        //判断用户是否登录
        var is_login =111;
        if (is_login) {
            var is_zhifubao_bind=false;
            if(is_zhifubao_bind){

            }else{
              api.confirm({
                  title: '提示：',
                  msg: '请绑定淘宝账号，点击确定，马上去绑定！',
                  buttons: ['确定', '取消']
              }, function(ret, err) {
                var index = ret.buttonIndex;
                if(index==1){
                  //alert('我是支付宝页面');
                  api.openWin({
                      name: 'taobao_bind',
                      url: './taobao_bind.html',
                      pageParam: {
                          name: 'test' //给登录页面传递参数
                      }
                  });
                }
              });
            }
            //发送一个ajax请求到接口，查看是否进行了支付宝验证；
            // api.ajax({
            //     url: SITE_URL+'index.php?m=api&c=appnew&a=goods_show&goods_id=' + goodId,
            //     method: 'get',
            // }, function(ret, err) {
            //     if (ret) {
            //       //如果可以请求接口成立
            //
            //
            //     } else {
            //         alert(JSON.stringify(err));
            //     }
            // });
            //如果没有绑定支付宝就弹出一个页面

        } else {
            api.confirm({
                title: '提示：',
                msg: '请先登录app',
                buttons: ['确定', '取消']
            }, function(ret, err) {

              var index = ret.buttonIndex;
              if(index==1){
                api.openWin({
                    name: 'login',
                    url: './login.html',
                    pageParam: {
                        name: 'test' //给登录页面传递参数
                    }
                });
              }
            });

        }
    }

    function initEventListenner() {

        api.addEventListener({
            name: 'keyback'
        }, function(ret, err) {
            api.confirm({
                title: '提示',
                msg: '是否退出应用',
                buttons: ['确定', '取消']
            }, function(ret, err) {
                if (ret.buttonIndex == 1) {
                    api.closeWidget({
                        silent: true
                    });
                }
            });
        });
    };
</script>

</html>
